import { createRouter, createWebHashHistory } from 'vue-router'
import localRoutes from '@/router/localRoutes'

// 扩展 RouteMeta 接口
declare module 'vue-router' {
  interface RouteMeta {
    id?: string | number
    title?: string
    icon?: string
    hide?: boolean
  }
}

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login.vue')
    },
    {
      path: '/',
      name: 'home',
      component: () => import('@/views/layout/index.vue'),
      redirect: '/welcome',
      children: [
        ...localRoutes,
        {
          path: '/welcome',
          name: 'welcome',
          component: () => import('@/views/Welcome.vue')
        },
        {
          path: '/:pathMatch(.*)*',
          name: '404',
          component: () => import('@/views/404.vue')
        }
      ]
    }
  ]
})

export default router
